package com.tms.qy.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.tms.qy.domain.TmsQy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tms.qy.service.ITmsQyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 企业Controller
 * 
 * @author ruoyi
 * @date 2024-10-25
 */
@RestController
@RequestMapping("/qy")
public class TmsQyController extends BaseController
{
    @Autowired
    private ITmsQyService tmsQyService;

    /**
     * 查询企业列表
     */
    @RequiresPermissions("qy:qy:list")
    @GetMapping("/list")
    public TableDataInfo list(TmsQy tmsQy)
    {
        startPage();
        List<TmsQy> list = tmsQyService.selectTmsQyList(tmsQy);
        return getDataTable(list);
    }

    /**
     * 导出企业列表
     */
    @RequiresPermissions("qy:qy:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, TmsQy tmsQy)
    {
        List<TmsQy> list = tmsQyService.selectTmsQyList(tmsQy);
        ExcelUtil<TmsQy> util = new ExcelUtil<TmsQy>(TmsQy.class);
        util.exportExcel(response, list, "企业数据");
    }

    /**
     * 获取企业详细信息
     */
    @RequiresPermissions("qy:qy:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tmsQyService.selectTmsQyById(id));
    }

    /**
     * 新增企业
     */
    @RequiresPermissions("qy:qy:add")
    @PostMapping
    public AjaxResult add(@RequestBody TmsQy tmsQy)
    {
        return toAjax(tmsQyService.insertTmsQy(tmsQy));
    }

    /**
     * 修改企业
     */
    @RequiresPermissions("qy:qy:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody TmsQy tmsQy)
    {
        return toAjax(tmsQyService.updateTmsQy(tmsQy));
    }

    /**
     * 删除企业
     */
    @RequiresPermissions("qy:qy:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tmsQyService.deleteTmsQyByIds(ids));
    }
}
